package djboom.materials.display.elements {
	import flash.events.Event;
	import flash.geom.ColorTransform;

	import org.casalib.display.CasaShape;

	/**
	 * .
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 30.04.2010
	 * 
	 */

	public class Rhombus extends CasaShape {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		public static const GRAY:uint = 0x888888;		public static const GREEN:uint = 0x709402;		public static const BLUE:uint = 0x08a6dc;		public static const WHITE:uint = 0xffffff;

		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		private var _colorTransform:ColorTransform = new ColorTransform();

		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function Rhombus(color:uint) {
			super();
			
			graphics.beginFill(color);
			graphics.moveTo(31, 0);
			graphics.lineTo(95, 0);
			graphics.lineTo(126, 54);
			graphics.lineTo(95, 108);
			graphics.lineTo(31, 108);
			graphics.lineTo(0, 54);
			graphics.lineTo(31, 0);
			graphics.lineTo(35, 5);
			graphics.lineTo(91, 5);
			graphics.lineTo(119, 54);
			graphics.lineTo(91, 103);
			graphics.lineTo(35, 103);
			graphics.lineTo(7, 54);
			graphics.lineTo(35, 5);
			graphics.lineTo(31, 0);
			graphics.endFill();
			
			addEventListener(Event.REMOVED_FROM_STAGE, clearContent);
		}	 

		// ----------------------------------------------------------------------------
		// Методы класса.
		// ----------------------------------------------------------------------------

		private function clearContent(event:Event):void {
			_colorTransform = null;
		}

		// ----------------------------------------------------------------------------
		// Публичные методы.
		// ----------------------------------------------------------------------------

		public function changeColor(color:uint):void {
			_colorTransform.color = color;
			this.transform.colorTransform = _colorTransform;
		}
		
		// ----------------------------------------------------------------------------
        // Публичные свойства.
        // ----------------------------------------------------------------------------
	}
}
